package com.ruoyi.util;

import com.ruoyi.DynamicClassInfo;
import com.ruoyi.common.core.domain.SuperEntity;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * **********************
 * * Author: XiaShiLong *
 * * Date  : 2021-05-13 *
 * * Time  : 15:52      *
 * * to    : lz&xm      *
 * **********************
 **/
public class SuperClassFilter {

    private static final List<String> SUPER_CLASS_ATTRIBUTES;

    static {
        SUPER_CLASS_ATTRIBUTES = Arrays.stream(SuperEntity.class.getDeclaredFields())
                .map(Field::getName)
                .collect(Collectors.toList());
    }

    public static boolean superFilter(DynamicClassInfo.FieldInfo fieldInfo) {
        return !SUPER_CLASS_ATTRIBUTES.contains(fieldInfo.getAttributeName());
    }
}
